package tr.edu.metu.is.mega.client.menu;

import tr.edu.metu.is.mega.client.UserDashboardWindow;
import tr.edu.metu.is.mega.client.core.MainWindow;
import tr.edu.metu.is.mega.client.course.admin.CourseManagementWindow;
import tr.edu.metu.is.mega.client.course.instructor.CourseInformationWindow;
import tr.edu.metu.is.mega.client.course.student.StudentCourseWindow;
import tr.edu.metu.is.mega.client.schedule.ScheduleTemplateManagementWindow;
import tr.edu.metu.is.mega.client.user.UserManagementWindow;
import tr.edu.metu.is.mega.client.user.profile.EditProfileWindow;

import com.google.gwt.core.client.GWT;

/**
 * Factory class to create instances of windows which are reached from the main
 * menu.
 */
public final class MenuWindowFactory {

    /**
     * Hidden constructor.
     */
    private MenuWindowFactory() {
    }

    /**
     * Creates and returns a window instance.
     * 
     * @param identifier window feature identifier
     * @return window instance
     */
    public static MainWindow getInstance(String identifier) {
        String window = identifier.split(":")[0];
        if (window.equalsIgnoreCase("UserDashboardWindow")) {
            return GWT.create(UserDashboardWindow.class);
        }
        if (window.equalsIgnoreCase("ProfileWindow")) {
            return GWT.create(EditProfileWindow.class);
        }
        if (window.equalsIgnoreCase("UserManagementWindow")) {
            return GWT.create(UserManagementWindow.class);
        }
        if (window.equalsIgnoreCase("ScheduleTemplateManagementWindow")) {
            return GWT.create(ScheduleTemplateManagementWindow.class);
        }
        if (window.equalsIgnoreCase("CourseManagementWindow")) {
            return GWT.create(CourseManagementWindow.class);
        }
        if (window.equalsIgnoreCase("CourseInformationWindow")) {
            return GWT.create(CourseInformationWindow.class);
        }
        if (window.equalsIgnoreCase("StudentCourseWindow")) {
            return GWT.create(StudentCourseWindow.class);
        }
        return GWT.create(UserDashboardWindow.class);
    }

}
